import Vue from "vue";
import VueRouter from "vue-router";
import TablePage from "@/pages/TablePage";
import DetailPage from "@/pages/DetailPage";
import SubDetailPage from "@/pages/SubDetailPage";

Vue.use(VueRouter);

const originPush = VueRouter.prototype.push;
VueRouter.prototype.push = function () {
  this.currentNavigateType = "push";
  return originPush.apply(this, [...arguments]);
};

const originReplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function () {
  this.currentNavigateType = "replace";
  return originReplace.apply(this, [...arguments]);
};

const originGo = VueRouter.prototype.go;
VueRouter.prototype.go = function () {
  this.currentNavigateType = "go";
  return originGo.apply(this, [...arguments]);
};

export default new VueRouter({
  routes: [
    { path: "/", name: "index", redirect: "/table" },
    { path: "/table", name: "table-page", component: TablePage },
    { path: "/detail/:key", name: "detail-page", component: DetailPage },
    { path: "/sub-detail/:key", name: "detail-page", component: SubDetailPage },
  ],
});
